package com.gtt.jr.action.base;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * Action 基类
 * 
 * @author 高甜甜(gao12581@sina.com)
 * @date 2010-8-20
 * 
 */
public abstract class BaseAction extends ActionSupport {

	protected static final String USERNAME = "username";

	private static final long serialVersionUID = 5874035887721623786L;

	public static final String ARROW = " > ";

	/**
	 * Get ContextPath.
	 * 
	 * @return contextPath
	 */
	public String getContextPath() {
		return ((HttpServletRequest) ActionContext.getContext().get(
				StrutsStatics.HTTP_REQUEST)).getContextPath();
	}
	
	public String getRealPath(){
		return ServletActionContext.getServletContext().getRealPath("/");
	}

	public String getBread() {
		return "后台管理";
	}

	@SuppressWarnings("unchecked")
	public Map getSession() {
		return ActionContext.getContext().getSession();
	}

	public boolean isLogin() {
		return getSession().containsKey(USERNAME);
	}
}
